/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.pruebas;

import java.io.File;
import java.util.HashMap;
import java.util.Map;
import net.sf.jasperreports.engine.*;

/**
 *
 * @author Martha
 */
public class ExportMain {

    public static void main(String[] args) {

        String fileName = ("D:\\ace\\report1.jasper");
        //out.print(fileName);

        File sourceFile = new File(fileName);

        /*String DRIVER = "org.postgresql.Driver";
        String URL = "jdbc:postgresql://192.168.53.20:5432/crm";
        Class.forName(DRIVER);
        Connection conn = DriverManager.getConnection(URL);
*/
        try {
            
            JasperPrint print = JasperFillManager.fillReport(sourceFile.getPath(), new HashMap());
            //comentario
            Map parametros = new HashMap();
            byte[] bytes = JasperRunManager.runReportToPdf(sourceFile.getPath(), parametros);
            JasperFillManager.fillReportToFile(sourceFile.getPath(), fileName, parametros);
            //response.setContentType("application/pdf");
            //response.setContentLength(bytes.length);
            //ServletOutputStream ouputStream = response.getOutputStream();
            //ouputStream.write(bytes, 0, bytes.length);
            //ouputStream.close();
        } catch (Exception ex) {
            System.out.println("error "+ ex.getMessage());
        }

    }
}
